<template>
  <div>
    <p>请输入用户名：<input type="text" v-model="form.name"></p>
    <p>请输入账号：<input type="text" v-model="form.username"></p>
    <p>请输入密码：<input type="text" v-model="form.password"></p>
    <p>请输入年纪：
      <select name="" id="" v-model="form.types">
        <option :value="i.id" v-for="i in ke">{{ i.name }}</option>

      </select>
    </p>
    <button @click="add">注册</button>

  </div>
</template>

<script>
export default {
  name: "kelogin",
  data() {
    return {
      ke: [],
      form: {}
    }
  },
  methods: {
    get_ke() {
      this.$axios.get('nian/')
        .then(res => {
          this.ke = res.data.list
        })
    },
    add() {
      this.$axios.post('stu/', this.form)
        .then(res => {
          if (res.data.code == 200) {
            alert('注册成功')
            this.form = {}
          } else {
            alert('注册失败')
          }

        })
    }
  },
  mounted() {
    this.get_ke()
  }
}
</script>

<style scoped>

</style>
